package com.mach.platform.domain.base;

import io.swagger.annotations.ApiModel;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @author Anonymous
 * @Name
 * @Description: 角色表
 * @date 2018/04/13   22:11
 */
@ApiModel(value = "角色表字段")
//@JsonIgnoreProperties(value = { "accounts" ,"permissions", "menus"}, ignoreUnknown = true, allowSetters = true)
@Data
@Entity
@Table(name = "role")
public class Role implements Serializable {

	private static final long serialVersionUID = -2009001209725837622L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private              Long id;
	private              String name;
	/**
	 * 角色内容
	 */
	private String content;

	private              String remark;
	/**
	 * 创建时间
	 */
	private String creationTime;

	/**
	 * 创建人
	 */
	private String creationBy;

	/**
	 * 更新时间
	 */
	private String updateTime;

	/**
	 * 更新人
	 */
	private String updateBy;

/*	*//**
	 * 不级联维护，设计数据太多： 用REFRESH  不用  CascadeType.PERSIST CascadeType.REMOVE
	 *//*
	@ManyToMany(targetEntity = Account.class, cascade = { CascadeType.PERSIST, CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@JoinTable(name = "role_account", joinColumns = { @JoinColumn(name = "role_id") }, inverseJoinColumns = {
			@JoinColumn(name = "account_id")
	})
	private Set<Account> accounts = new HashSet<>();

	@ManyToMany(fetch = FetchType.LAZY, targetEntity = Permission.class, cascade = { CascadeType.REFRESH })
	@JoinTable(name = "role_perm", joinColumns = { @JoinColumn(name = "role_id") }, inverseJoinColumns = {
			@JoinColumn(name = "perm_id")
	})
	private Set<Permission> permissions = new HashSet<>();

    @OneToMany(targetEntity = Menu.class, cascade = { CascadeType.REFRESH })
    @JoinTable(name = "role_menu", joinColumns = { @JoinColumn(name = "role_id") }, inverseJoinColumns = {
            @JoinColumn(name = "menu_id")
    })
    private Set<Menu> menus = new HashSet<>();*/

}
